package com.khong.baodizhen.activity;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;

import com.khong.baodizhen.Constant;
import com.khong.baodizhen.R;

public class DBZCheckManamgerActivity extends TabActivity implements
		OnCheckedChangeListener {
	public TabHost tabhost;
	private RadioGroup radioGroup;

	// private RadioButton radioBtn;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dbz_manager_detail);

		tabhost = getTabHost();
		radioGroup = (RadioGroup) findViewById(R.id.radiogroup);
		// radioBtn = (RadioButton) findViewById(R.id.radio_1);

		radioGroup.setOnCheckedChangeListener(this);

		Intent msgIntent = new Intent(this, DBZCompanyInfoActivity.class);
		msgIntent.putExtra("data", getIntent().getSerializableExtra("data"));
		tabhost.addTab(tabhost.newTabSpec(Constant.JICHUXINXI_TABSPEC)
				.setIndicator(Constant.JICHUXINXI_TABSPEC)
				.setContent(msgIntent));

		Intent contactsList = new Intent(this,
				DBZCompanyCheckItemActivity.class);
		contactsList.putExtra("data", "1");

		tabhost.addTab(tabhost.newTabSpec(Constant.JIANCHAXIANG_TABSPEC)
				.setIndicator(Constant.JIANCHAXIANG_TABSPEC)
				.setContent(contactsList));

		Intent contactsOwer = new Intent(this,
				DBZCompanyCheckYJActivity.class);
		contactsOwer.putExtra("data", "1");
		tabhost.addTab(tabhost.newTabSpec(Constant.CHULIYIJIAN_TABSPEC)
				.setIndicator(Constant.CHULIYIJIAN_TABSPEC)
				.setContent(contactsOwer));

		Intent dialing = new Intent(this, DBZCompanyPapersActivity.class);
		tabhost.addTab(tabhost.newTabSpec(Constant.WENSHU_TABSPEC)
				.setIndicator(Constant.WENSHU_TABSPEC).setContent(dialing));

	}

	@Override
	public void onCheckedChanged(RadioGroup group, int checkedId) {
		switch (checkedId) {
		case R.id.radio_1:
			System.out.println("=====radio_1=====");
			tabhost.setCurrentTabByTag(Constant.JICHUXINXI_TABSPEC);

			break;
		case R.id.radio_2:
			System.out.println("=====radio_5=====");
			tabhost.setCurrentTabByTag(Constant.JIANCHAXIANG_TABSPEC);

			break;
		case R.id.radio_3:
			System.out.println("=====radio_6=====");
			tabhost.setCurrentTabByTag(Constant.CHULIYIJIAN_TABSPEC);

			break;
		case R.id.radio_4:
			System.out.println("=====radio_4=====");
			tabhost.setCurrentTabByTag(Constant.WENSHU_TABSPEC);
			break;

		default:
			break;
		}
	}

	@Override
	protected void onRestart() {
		System.out.println("======onRestart======");
		// tabhost.setCurrentTabByTag(Constant.CONTACTSLIST_TABSPEC);
		// radioBtn.setChecked(true);
		super.onRestart();
	}

}